with Interfaces.C; use Interfaces.C;
with SDL_stdinc_h;
with Interfaces.C.Strings;

package SDL_cdrom_h is


  SDL_MAX_TRACKS : constant := 99;  --  SDL_cdrom.h:43

  SDL_AUDIO_TRACK : constant := 16#00#;  --  SDL_cdrom.h:46
  SDL_DATA_TRACK : constant := 16#04#;  --  SDL_cdrom.h:47
  --  arg-macro: function CD_INDRIVE (status)
  --    return (int)(status) > 0;

  CD_FPS : constant := 75;  --  SDL_cdrom.h:82
  --  unsupported macro: FRAMES_TO_MSF(f,M,S,F) { int value = f; *(F) = value%CD_FPS; value /= CD_FPS; *(S) = value%60; value /= 60; *(M) = value; }
  --  unsupported macro: MSF_TO_FRAMES(M,S,F) ((M)*60*CD_FPS+(S)*CD_FPS+(F))

  --    SDL - Simple DirectMedia Layer
  --    Copyright (C) 1997-2006 Sam Lantinga
  --    This library is free software; you can redistribute it and/or
  --    modify it under the terms of the GNU Lesser General Public
  --    License as published by the Free Software Foundation; either
  --    version 2.1 of the License, or (at your option) any later version.
  --    This library is distributed in the hope that it will be useful,
  --    but WITHOUT ANY WARRANTY; without even the implied warranty of
  --    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  --    Lesser General Public License for more details.
  --    You should have received a copy of the GNU Lesser General Public
  --    License along with this library; if not, write to the Free Software
  --    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  --    Sam Lantinga
  --    slouken@libsdl.org
  -- 

  -- This is the CD-audio control API for Simple DirectMedia Layer  
  -- Set up for C function definitions, even when using C++  
  -- In order to use these functions, SDL_Init() must have been called
  --   with the SDL_INIT_CDROM flag.  This causes SDL to scan the system
  --   for CD-ROM drives, and load appropriate drivers.
  -- 

  -- The maximum number of CD-ROM tracks on a disk  
  -- The types of CD-ROM track possible  
  -- The possible states which a CD-ROM drive can be in.  
   subtype CDstatus is unsigned;
   CD_TRAYEMPTY : constant CDstatus := 0;
   CD_STOPPED : constant CDstatus := 1;
   CD_PLAYING : constant CDstatus := 2;
   CD_PAUSED : constant CDstatus := 3;
   CD_ERROR : constant CDstatus := -1;  -- SDL_cdrom.h:56:3

  -- Given a status, returns true if there's a disk in the drive  
  -- Track number  
   type SDL_CDtrack is record
      id : aliased SDL_stdinc_h.Uint8;  -- SDL_cdrom.h:62:8
      c_type : aliased SDL_stdinc_h.Uint8;  -- SDL_cdrom.h:63:8
      unused : aliased SDL_stdinc_h.Uint16;  -- SDL_cdrom.h:64:9
      length : aliased SDL_stdinc_h.Uint32;  -- SDL_cdrom.h:65:9
      offset : aliased SDL_stdinc_h.Uint32;  -- SDL_cdrom.h:66:9
   end record;
   pragma Convention (C, SDL_CDtrack);  -- SDL_cdrom.h:61:28

  -- Data or audio track  
  -- Length, in frames, of this track  
  -- Offset, in frames, from start of disk  
  -- This structure is only current as of the last call to SDL_CDStatus()  
  -- Private drive identifier  
   type SDL_CD_track_array is array (0 .. 99) of aliased SDL_CDtrack;
   type SDL_CD is record
      id : aliased int;  -- SDL_cdrom.h:71:6
      status : aliased CDstatus;  -- SDL_cdrom.h:72:11
      numtracks : aliased int;  -- SDL_cdrom.h:75:6
      cur_track : aliased int;  -- SDL_cdrom.h:76:6
      cur_frame : aliased int;  -- SDL_cdrom.h:77:6
      track : aliased SDL_CD_track_array;  -- SDL_cdrom.h:78:36
   end record;
   pragma Convention (C, SDL_CD);  -- SDL_cdrom.h:70:23

  -- Current drive status  
  -- The rest of this structure is only valid if there's a CD in drive  
  -- Number of tracks on disk  
  -- Current track position  
  -- Current frame offset within current track  
  -- Conversion functions from frames to Minute/Second/Frames and vice versa  
  -- CD-audio API functions:  
  -- Returns the number of CD-ROM drives on the system, or -1 if
  --   SDL_Init() has not been called with the SDL_INIT_CDROM flag.
  --  

   function SDL_CDNumDrives return int;  -- SDL_cdrom.h:98:49
   pragma Import (C, SDL_CDNumDrives, "SDL_CDNumDrives");

  -- Returns a human-readable, system-dependent identifier for the CD-ROM.
  --   Example:
  --	"/dev/cdrom"
  --	"E:"
  --	"/dev/disk/ide/1/master"
  -- 

   function SDL_CDName (drive : int) return Interfaces.C.Strings.chars_ptr;  -- SDL_cdrom.h:106:58
   pragma Import (C, SDL_CDName, "SDL_CDName");

  -- Opens a CD-ROM drive for access.  It returns a drive handle on success,
  --   or NULL if the drive was invalid or busy.  This newly opened CD-ROM
  --   becomes the default CD used when other CD functions are passed a NULL
  --   CD-ROM handle.
  --   Drives are numbered starting with 0.  Drive 0 is the system default CD-ROM.
  -- 

   function SDL_CDOpen (drive : int) return access SDL_CD;  -- SDL_cdrom.h:114:54
   pragma Import (C, SDL_CDOpen, "SDL_CDOpen");

  -- This function returns the current status of the given drive.
  --   If the drive has a CD in it, the table of contents of the CD and current
  --   play position of the CD will be stored in the SDL_CD structure.
  -- 

   function SDL_CDStatus (cdrom : access SDL_CD) return CDstatus;  -- SDL_cdrom.h:120:60
   pragma Import (C, SDL_CDStatus, "SDL_CDStatus");

  -- Play the given CD starting at 'start_track' and 'start_frame' for 'ntracks'
  --   tracks and 'nframes' frames.  If both 'ntrack' and 'nframe' are 0, play 
  --   until the end of the CD.  This function will skip data tracks.
  --   This function should only be called after calling SDL_CDStatus() to 
  --   get track information about the CD.
  --   For example:
  --	// Play entire CD:
  --	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
  --		SDL_CDPlayTracks(cdrom, 0, 0, 0, 0);
  --	// Play last track:
  --	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) ) {
  --		SDL_CDPlayTracks(cdrom, cdrom->numtracks-1, 0, 0, 0);
  --	}
  --	// Play first and second track and 10 seconds of third track:
  --	if ( CD_INDRIVE(SDL_CDStatus(cdrom)) )
  --		SDL_CDPlayTracks(cdrom, 0, 0, 2, 10);
  --   This function returns 0, or -1 if there was an error.
  -- 

   function SDL_CDPlayTracks
     (cdrom : access SDL_CD;
      start_track : int;
      start_frame : int;
      ntracks : int;
      nframes : int) return int;  -- SDL_cdrom.h:142:61
   pragma Import (C, SDL_CDPlayTracks, "SDL_CDPlayTracks");

  -- Play the given CD starting at 'start' frame for 'length' frames.
  --   It returns 0, or -1 if there was an error.
  -- 

   function SDL_CDPlay
     (cdrom : access SDL_CD;
      start : int;
      length : int) return int;  -- SDL_cdrom.h:147:76
   pragma Import (C, SDL_CDPlay, "SDL_CDPlay");

  -- Pause play -- returns 0, or -1 on error  
   function SDL_CDPause (cdrom : access SDL_CD) return int;  -- SDL_cdrom.h:150:54
   pragma Import (C, SDL_CDPause, "SDL_CDPause");

  -- Resume play -- returns 0, or -1 on error  
   function SDL_CDResume (cdrom : access SDL_CD) return int;  -- SDL_cdrom.h:153:55
   pragma Import (C, SDL_CDResume, "SDL_CDResume");

  -- Stop play -- returns 0, or -1 on error  
   function SDL_CDStop (cdrom : access SDL_CD) return int;  -- SDL_cdrom.h:156:53
   pragma Import (C, SDL_CDStop, "SDL_CDStop");

  -- Eject CD-ROM -- returns 0, or -1 on error  
   function SDL_CDEject (cdrom : access SDL_CD) return int;  -- SDL_cdrom.h:159:54
   pragma Import (C, SDL_CDEject, "SDL_CDEject");

  -- Closes the handle for the CD-ROM drive  
   procedure SDL_CDClose (cdrom : access SDL_CD);  -- SDL_cdrom.h:162:55
   pragma Import (C, SDL_CDClose, "SDL_CDClose");

  -- Ends C function definitions when using C++  
end SDL_cdrom_h;
